#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string, vector<string>> hash;
        vector<string> num;
        vector<vector<string>> ret;
        for (auto& st : strs)
        {
            string tmp = st;
            sort(tmp.begin(), tmp.end());
            if (hash.count(tmp)) hash[tmp].push_back(st);
            else
            {
                hash[tmp].push_back(st);
                num.push_back(tmp);
            }
        }
        for (auto& st : num)
        {
            ret.push_back(hash[st]);
        }
        return ret;
    }
};